package com.controller.login;


import com.comm.R;
import com.service.setting.SysEmployeeService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping(value = "/login")
@Api(value = "用户登录模块",tags = "登录的所有接口")
public class LoginController {

    @Autowired
    private SysEmployeeService sysEmployeeService;

    /**
     * 登录
     * @param empUserName
     * @param empPassword
     * @return
     */
    @GetMapping(value = "/sulogin")
    @ApiOperation(value = "登录",notes = "登录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "empUserName",value = "用户名",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "empPassword",value = "密码",paramType = "query",dataType = "String",required = true)
    })
    public R login(String empUserName, String empPassword, HttpServletResponse response){

        return sysEmployeeService.login(empUserName,empPassword,response);


    }

    /**
     * 初始化菜单
     * @return
     */
    @GetMapping(value = "/initMenu")
    @ApiOperation(value = "这个是登录后初始化菜单的接口，必须登录后才能用",notes = "初始化菜单")
    public String initMenu(){



        return "{\n" +
                "  \"homeInfo\": {\n" +
                "    \"menuName\": \"诊所收支统计\",\n" +
                "    \"menuUrl\": \"/data/revAndExp\",\n" +
                "    \"componentName\": \"revAndExp\",\n" +
                "    \"componentView\":\"/Data/RevAndExp\"\n" +
                "  },\n" +
                "  \"logoInfo\": {\n" +
                "    \"menuName\": \"源码力量云诊所\",\n" +
                "    \"menuImage\": \"/images/logo.png\"\n" +
                "  },\n" +
                "  \"menuInfo\": [\n" +
                "\n" +
                "    {\n" +
                "      \"menuId\": 2,\n" +
                "      \"menuName\": \"看病就诊\",\n" +
                "      \"menuUrl\": \"/treat\",\n" +
                "      \"componentName\":\"treat\",\n" +
                "      \"menuImgClass\": \"iconfont icon-shouye\",\n" +
                "      \"componentView\":\"/Treat\",\n" +
                "      \"menuChilds\": [\n" +
                "        {\n" +
                "          \"menuId\": 8,\n" +
                "          \"menuName\": \"新开就诊\",\n" +
                "          \"menuUrl\": \"/treat/createTreat\",\n" +
                "          \"componentName\":\"createTreat\",\n" +
                "          \"menuImgClass\": \"iconfont icon-shouye\",\n" +
                "          \"componentView\":\"/Treat/CreateTreat\"\n" +
                "        },{\n" +
                "          \"menuId\": 9,\n" +
                "          \"menuName\": \"就诊列表\",\n" +
                "          \"menuUrl\": \"/treat/treatList\",\n" +
                "          \"componentName\":\"treatList\",\n" +
                "          \"menuImgClass\": \"iconfont icon-shouye\",\n" +
                "          \"componentView\":\"/Treat/TreatList\"\n" +
                "        },{\n" +
                "          \"menuId\": 10,\n" +
                "          \"menuName\": \"医生排班\",\n" +
                "          \"menuUrl\": \"/treat/doctorScheduling\",\n" +
                "          \"componentName\":\"doctorScheduling\",\n" +
                "          \"menuImgClass\": \"iconfont icon-shouye\",\n" +
                "          \"componentView\":\"/Reat/DoctorScheduling\"\n" +
                "        }\n" +
                "      ]\n" +
                "    },\n" +
                "    {\n" +
                "      \"menuId\": 3,\n" +
                "      \"menuName\": \"收费发药\",\n" +
                "      \"menuUrl\": \"/chargeDispensing\",\n" +
                "      \"componentName\":\"chargeDispensing\",\n" +
                "      \"menuImgClass\": \"iconfont icon-shouye\",\n" +
                "      \"componentView\":\"/ChargeDispensing\",\n" +
                "      \"menuChilds\": [\n" +
                "        {\n" +
                "          \"menuId\": 11,\n" +
                "          \"menuName\": \"收费发药\",\n" +
                "          \"menuUrl\": \"/chargeDispensing/chargeDispensing\",\n" +
                "          \"componentName\":\"chargeDispensing\",\n" +
                "          \"menuImgClass\": \"iconfont icon-shouye\",\n" +
                "          \"componentView\":\"/ChargeDispensing/ChargeDispensing\"\n" +
                "        }\n" +
                "      ]\n" +
                "    },\n" +
                "    {\n" +
                "      \"menuId\": 4,\n" +
                "      \"menuName\": \"药品进销存\",\n" +
                "      \"menuUrl\": \"/medicine\",\n" +
                "      \"componentName\":\"medicine\",\n" +
                "      \"menuImgClass\": \"iconfont icon-shouye\",\n" +
                "      \"componentView\":\"/Medicine\",\n" +
                "      \"menuChilds\": [\n" +
                "        {\n" +
                "          \"menuId\": 12,\n" +
                "          \"menuName\": \"药品信息维护\",\n" +
                "          \"menuUrl\": \"/medicine/message\",\n" +
                "          \"componentName\":\"message\",\n" +
                "          \"menuImgClass\": \"iconfont icon-shouye\",\n" +
                "          \"componentView\":\"/Medicine/Message\"\n" +
                "        }\n" +
                "      ]\n" +
                "    },\n" +
                "    {\n" +
                "      \"menuId\": 5,\n" +
                "      \"menuName\": \"数据统计\",\n" +
                "      \"menuUrl\": \"/data\",\n" +
                "      \"componentName\":\"data\",\n" +
                "      \"menuImgClass\": \"iconfont icon-shouye\",\n" +
                "      \"componentView\":\"/Data\",\n" +
                "      \"menuChilds\": [\n" +
                "        {\n" +
                "          \"menuId\": 14,\n" +
                "          \"menuName\": \"诊所收支统计\",\n" +
                "          \"menuUrl\": \"/data/revAndExp\",\n" +
                "          \"componentName\":\"revAndExp\",\n" +
                "          \"menuImgClass\": \"iconfont icon-shouye\",\n" +
                "          \"componentView\":\"/Data/RevAndExp\"\n" +
                "        }\n" +
                "      ]\n" +
                "    },\n" +
                "    {\n" +
                "      \"menuId\": 6,\n" +
                "      \"menuName\": \"系统设置\",\n" +
                "      \"menuUrl\": \"/setting\",\n" +
                "      \"componentName\":\"setting\",\n" +
                "      \"menuImgClass\": \"iconfont icon-shouye\",\n" +
                "      \"componentView\":\"/Setting\",\n" +
                "      \"menuChilds\": [\n" +
                "        {\n" +
                "          \"menuId\": 15,\n" +
                "          \"menuName\": \"医生管理\",\n" +
                "          \"menuUrl\": \"/setting/doctor\",\n" +
                "          \"componentName\":\"doctor\",\n" +
                "          \"menuImgClass\": \"iconfont icon-shouye\",\n" +
                "          \"componentView\":\"/Setting/Doctor\"\n" +
                "        }\n" +
                "      ]\n" +
                "    }\n" +
                "  ]\n" +
                "}";

    }


    /**
     * 登录后得到当前用户信息
     * @return
     */
    @GetMapping("/getCurrentEmp")
    @ApiOperation(value = "这个是登录后主页的用户信息，必须登录后才能用",notes = "获取当前用户信息")
    public String getEmpBaseMsg(){

        return "{\n" +
                "  \"code\": 200,\n" +
                "  \"msg\": \"成功！\",\n" +
                "  \"data\": [{\n" +
                "    \"id\": 111,\n" +
                "    \"empName\":\"张三\"\n" +
                "  }]\n" +
                "}";


    }


    @PostMapping("/logOut")
    @ApiOperation(value = "这个是登录后退出登录功能，必须登录后才能用",notes = "退出登录")
    public String logOut(){

        return "{\n" +
                "\t\"code\": 200,\n" +
                "\t\"msg\": \"登出成功！\",\n" +
                "\t\"data\": []\n" +
                "}";

    }

}
